package org.linlinjava.litemall.wx.controller;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.wx.annotation.LogAnno;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.WxBalancePayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 支付平衡控制器
 *
 * @author yliyun
 * @description：余额支付
 * @date 2022/09/14
 */

@RestController
@RequestMapping("/wx/balance")
public class BalancePayController {

    /**
     * 余额支付服务
     */
    @Autowired
    private WxBalancePayService balancePayService;


    /**
     * 支付
     *
     * @param userId 用户id
     * @param body   身体
     * @return {@link Object}
     */
    @PostMapping("pay")
    @LogAnno
    public Object pay(@LoginUser Integer userId, @RequestBody String body){
        if(userId == null){
            return ResponseUtil.unlogin();
        }

        return balancePayService.pay(userId, body);
    }
}
